﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DataObjects.ADO;

namespace WindowsFormsApplication1
{
    public partial class form_Report_ThongKeMuon : DevComponents.DotNetBar.Controls.SlidePanel
    {
        SqlTinhHinhMuonSach _sqlMuon = new SqlTinhHinhMuonSach();
        SqlBCTinhHinhMuon _sqlBCMuon = new SqlBCTinhHinhMuon();
      
        public form_Report_ThongKeMuon()
        {
            InitializeComponent();
        }
        
        public void UpdateSize()
        {
            this.Size = ((DevComponents.DotNetBar.Metro.MetroForm)MainForm._mainForm).Size;
        }

        public void ShowSlide()
        {
            this.IsOpen = true;
            UpdateSize();
        }

        private void butThoat_Click(object sender, EventArgs e)
        {
            this.IsOpen = false;
        }

        private void butReport_Click(object sender, EventArgs e)
        {
            DataTable table = _sqlMuon.GetTable();
            table.Namespace = "Creport_TinhHinhMuon";
            createCrystalReportSource(table);

            table.Clear();
            table = _sqlBCMuon.GetTable();
            table.Namespace = "Creport_CT_TinhHinhMuon";
            createCrystalReportSource(table);
        }

        private void createCrystalReportSource(DataTable table)
        {
            string path = Application.StartupPath;
            path = path.Substring(0, path.LastIndexOf("bin"));

            table.TableName = "Creport_TraTre";
            table.WriteXmlSchema(path + @"\" + table.Namespace + ".rpt");
        }
    }
}
